﻿using System.Collections.Generic;
using Microsoft.Xna.Framework.Content;

namespace ShevaEngine.Core.Modules.Animations
{
    /// <summary>
    /// A collection of animation channels or tracks, which are sections of an
    /// animation that run for one bone.
    /// </summary>
    [ContentSerializerRuntimeTypeAttribute("ShevaEngine.Core.Modules.Animations.AnimationChannelCollection, ShevaEngine2")]
    public class AnimationChannelCollection : Dictionary<string, BoneKeyframeCollection>
    {
        /// <summary>Affected bones.</summary>
        public List<string> AffectedBones
        {
            get { return new List<string>(this.Keys); }
        }

        /// <summary>
        /// Konstruktor pro content pipeline.
        /// </summary>
        public AnimationChannelCollection()
            : base()
        { }

        // This immutable data structure should not be created by the library user
        public AnimationChannelCollection(Dictionary<string, BoneKeyframeCollection> channels)
            : base(channels)
        {
            ////            Debugger.Launch();

            //            // Find the affected bones
            //            //this.affectedBones = new List<string>();
            //            this.BoneKeyframes = new Dictionary<string, BoneKeyframeCollection>();

            //            foreach (BoneKeyframeCollection frames in channels)
            //            {
            //                BoneKeyframes.Add(frames.BoneName, frames);
            //              //  affectedBones.Add(frames.BoneName);
            //            }                       
        }

        ///// <summary>
        ///// Gets the BoneKeyframeCollection that is associated with the given bone.
        ///// </summary>
        ///// <param name="boneName">The name of the bone that contains a track in this
        ///// AnimationChannelCollection.</param>
        ///// <returns>The track associated with the given bone.</returns>
        //[ContentSerializerIgnore]
        //public BoneKeyframeCollection this[string boneName]
        //{
        //    get { return this[boneName]; }
        //}

        // See AnimationInfo's equivalent method for documentation        
        public bool AffectsBone(string boneName)
        {
            return this.ContainsKey(boneName);
        }
    }
}
